*********************************************************
*********************************************************  
*** GBR 2024 --- JPE Revision Package *******************
*** Code for stats analyses, Appendix C Parameters ******
*** Public (anonymized) *********************************
*********************************************************


**************************
**** Clean Data  *********
**************************

clear all
set more off

cd ".../JPEReplicationPackageDataverse/"
qui: do GBR24CleaningStudy1.do
qui: do GBR24CleaningStudy2.do
qui: do GBR24CleaningStudy3.do
qui: do GBR24CleaningStudy6.do



**************************
**** Data Preparation ****
**************************

clear all
set more off

** Load datasets from Studies 1, 2, 3, and 6
append using ///
".../JPEReplicationPackageDataverse/GBR24DataCleanStudy3.dta" ///
".../JPEReplicationPackageDataverse/GBR24DataCleanStudy2.dta" ///
".../JPEReplicationPackageDataverse/GBR24DataCleanStudy1.dta" ///
".../JPEReplicationPackageDataverse/GBR24DataCleanStudy6.dta", force

** Order observations by id (1 000 000 ids are from Study 1, 2 000 000 ids from Study2, 3 000 000 ids from Study 3)
order id

** Write zero for period indicators from other studies (they have missing data
* due to to the data construction)
quietly forvalues j=0(1)19 {
 replace period`j'=0 if period`j'==.
}
quietly forvalues j=25(1)28 {
 replace period`j'=0 if period`j'==.
}

** Remove workers in implicit discrimination treatment (unique to Study 2)
drop if lowwage_UID==1 | highwage_UID==1

** Generate alternative dummies for studies
gen study1=0
replace study1=1 if study==1
gen study2=0
replace study2=1 if study==2
gen study3=0
replace study3=1 if study==3
gen study6=0
replace study6=1 if study==6
label variable study1 "Indicator for Study 1"
label variable study2 "Indicator for Study 2"
label variable study3 "Indicator for Study 3"
label variable study6 "Indicator for Study 6"

** Log values of labor supply rescaled by adding 1 line, to avoid log(0)
gen lnl=ln(l+1)
label variable lnl "Log labor supply + 1 line"

** Log values of labor supply dropping those with zero labor supply, to avoid log(0)
gen lnl_withoutzero=ln(l) if l!=0
label variable lnl_withoutzero "Labor supply exluding observations with zero labor supply"

** Log values of alternative rescaled labor supply (+0.1 lines, +2 lines, +5 lines)
gen lnl_add01=ln(l+0.1)
gen lnl_add2=ln(l+2)
gen lnl_add5=ln(l+5)
label variable lnl_add01 "Alternative log labor supply + 0.1 lines"
label variable lnl_add2 "Alternative log labor supply + 2 lines"
label variable lnl_add5 "Alternative log labor supply + 5 lines"

** Indicator denoting that exisiting data for all demographics used in estimation
gen alldemographics=0
replace alldemographics=1 if nat_uk!=. & student!=. & employed!=. & parttime!=. & notInPaidJob!=. & age!=. & num_approvals!=. & prolific_score!=.
label variable alldemographics "All demographics used in estimation are present"



**************************
*** Text *****************
**************************



* Number of workers, low-wage workers, and high-wage workers in Study 6
count if study==6
count if low_wage==1 & study==6
count if high_wage==1 & study==6

* Footnote: number of workers without inequality or discrimination in Studies 1-3 and in Study 2
count if dis_ineq==0 & adv_ineq==0 & d_dis_ineq==0 & d_adv_ineq==0 & study==1 | ///
dis_ineq==0 & adv_ineq==0 & d_dis_ineq==0 & d_adv_ineq==0 & study==3
count if dis_ineq==0 & adv_ineq==0 & d_dis_ineq==0 & d_adv_ineq==0 & study==2

* Footnote: percentage of workers providing zero labor supply
tab l
di 164/5322

* Approx. elasticity of labor supply with respect to wage (gamma=7.5, so=0.13)
di 1/7.5

* The estimated percentage increase in wage (65%--83%) to face negative gender discrimination are given by the delta_n parameter estimates in Table C1 columns 1 and 2 (0.830 and 0.650)
* The equivalent GBP wage compensations at a wage of 0.03 GPB per line are approx. 0.02 GBP and 0.025 GPB
di 0.65*0.03
di 0.83*0.03

* For women, the estimated percentage increase in wage (74%--92%) to face negative gender discrimination are given by the delta_n_wom parameter estimates in Table C1 columns 3 and 4 (0.922 and 0.735)



**************************
*** Table  **************
**************************



** Table C1: Parameter Estimates
eststo clear
** Log of labor supply + 1
* Column 1: with demographics
eststo: nl (lnl = ( (1/{g=2})*(ln(w - {alpha=0.2}*dis_ineq - {beta=0.2}*adv_ineq - {delta_n=0.5}*d_dis_ineq - {delta_p=0.1}*d_adv_ineq)  - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /alpha=/delta_n
test /beta=/delta_p
* Without demographics (not in table)
nl (lnl = ( (1/{g=2})*(ln(w - {alpha=0.2}*dis_ineq - {beta=0.2}*adv_ineq - {delta_n=0.5}*d_dis_ineq - {delta_p=0.1}*d_adv_ineq)  - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6) ) ), vce(robust)
test /alpha=/delta_n

** Log of labor supply without those with zero labor
* Column 2: with demographics
eststo: nl (lnl_withoutzero = ( (1/{g=2})*(ln(w - {alpha=0.2}*dis_ineq - {beta=0.2}*adv_ineq - {delta_n=0.5}*d_dis_ineq - {delta_p=0.1}*d_adv_ineq)  - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /alpha=/delta_n
test /beta=/delta_p
* without demographics (not in table)
nl (lnl_withoutzero = ( (1/{g=2})*(ln(w - {alpha=0.2}*dis_ineq - {beta=0.2}*adv_ineq - {delta_n=0.5}*d_dis_ineq - {delta_p=0.1}*d_adv_ineq)  - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6) ) ), vce(robust)
test /alpha=/delta_n

** Log of labor supply + 1, with gender differences in parameters
* Column 3: with demographics
eststo: nl (lnl = ( (1/{g=2})*(ln(w - {w_alpha=0}*dis_ineq*woman -  {w_beta=0}*adv_ineq*woman - {w_delta_n=0}*d_dis_ineq*woman - {w_delta_p=0}*d_adv_ineq*woman - {m_alpha=0}*dis_ineq*(1-woman) - {m_beta=0}*adv_ineq*(1-woman) - {m_delta_n=-0.1}*d_dis_ineq*(1-woman) - {m_delta_p=0.2}*d_adv_ineq*(1-woman)) - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /w_delta_n=/w_alpha
test /m_delta_n=/m_alpha
test /w_delta_p=/w_beta
test /m_delta_p=/m_beta
test /w_delta_n=/m_delta_n
test /w_delta_p=/m_delta_p
* without demographics (not in table)
nl (lnl = ( (1/{g=2})*(ln(w - {w_alpha=0}*dis_ineq*woman -  {w_beta=0}*adv_ineq*woman - {w_delta_n=0}*d_dis_ineq*woman - {w_delta_p=0}*d_adv_ineq*woman - {m_alpha=0}*dis_ineq*(1-woman) - {m_beta=0}*adv_ineq*(1-woman) - {m_delta_n=-0.1}*d_dis_ineq*(1-woman) - {m_delta_p=0.2}*d_adv_ineq*(1-woman)) - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6) ) ), vce(robust)

** Log of labor supply without those with zero labor, with gender differences in parameters
* Column 4: with demographics
eststo: nl (lnl_withoutzero = ( (1/{g=2})*(ln(w - {w_alpha=0}*dis_ineq*woman -  {w_beta=0}*adv_ineq*woman - {w_delta_n=0}*d_dis_ineq*woman - {w_delta_p=0}*d_adv_ineq*woman - {m_alpha=0}*dis_ineq*(1-woman) - {m_beta=0}*adv_ineq*(1-woman) - {m_delta_n=-0.1}*d_dis_ineq*(1-woman) - {m_delta_p=0.2}*d_adv_ineq*(1-woman)) - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /w_delta_n=/w_alpha
test /m_delta_n=/m_alpha
test /w_delta_p=/w_beta
test /m_delta_p=/m_beta
test /w_delta_n=/m_delta_n
test /w_delta_p=/m_delta_p
* without demographics (not in table)
nl (lnl_withoutzero = ( (1/{g=2})*(ln(w - {w_alpha=0}*dis_ineq*woman -  {w_beta=0}*adv_ineq*woman - {w_delta_n=0}*d_dis_ineq*woman - {w_delta_p=0}*d_adv_ineq*woman - {m_alpha=0}*dis_ineq*(1-woman) - {m_beta=0}*adv_ineq*(1-woman) - {m_delta_n=-0.1}*d_dis_ineq*(1-woman) - {m_delta_p=0.2}*d_adv_ineq*(1-woman)) - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6) ) ), vce(robust)

* Export
esttab using ".../JPEReplicationPackageDataverse/Tables/TableC1_core_ParameterEstimates.tex", replace onecell se(3) b(3) compress star(* 0.10 ** 0.05 *** 0.01 **** 0.001)




****  Alternatives to adding 1 line to the labor supply before taking its log, to avoid log of zero when the labor supply is 0 line **** 

** Alternative 1, log of labor supply +0.1 lines
* Alternative 1, column 1: with demographics
eststo: nl (lnl_add01 = ( (1/{g=2})*(ln(w - {alpha=0.2}*dis_ineq - {beta=0.2}*adv_ineq - {delta_n=0.5}*d_dis_ineq - {delta_p=0.1}*d_adv_ineq)  - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /alpha=/delta_n
test /beta=/delta_p
* Alternative 1, column 3: with demographics
eststo: nl (lnl_add01 = ( (1/{g=2})*(ln(w - {w_alpha=0}*dis_ineq*woman -  {w_beta=0}*adv_ineq*woman - {w_delta_n=0}*d_dis_ineq*woman - {w_delta_p=0}*d_adv_ineq*woman - {m_alpha=0}*dis_ineq*(1-woman) - {m_beta=0}*adv_ineq*(1-woman) - {m_delta_n=-0.1}*d_dis_ineq*(1-woman) - {m_delta_p=0.2}*d_adv_ineq*(1-woman)) - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /w_delta_n=/w_alpha
test /m_delta_n=/m_alpha
test /w_delta_p=/w_beta
test /m_delta_p=/m_beta
test /w_delta_n=/m_delta_n
test /w_delta_p=/m_delta_p


** Alternative 2, log of labor supply +2 lines
* Alternative 2, column 1: with demographics
eststo: nl (lnl_add2 = ( (1/{g=2})*(ln(w - {alpha=0.2}*dis_ineq - {beta=0.2}*adv_ineq - {delta_n=0.5}*d_dis_ineq - {delta_p=0.1}*d_adv_ineq)  - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /alpha=/delta_n
test /beta=/delta_p
* Alternative 2, column 3: with demographics
eststo: nl (lnl_add2 = ( (1/{g=2})*(ln(w - {w_alpha=0}*dis_ineq*woman -  {w_beta=0}*adv_ineq*woman - {w_delta_n=0}*d_dis_ineq*woman - {w_delta_p=0}*d_adv_ineq*woman - {m_alpha=0}*dis_ineq*(1-woman) - {m_beta=0}*adv_ineq*(1-woman) - {m_delta_n=-0.1}*d_dis_ineq*(1-woman) - {m_delta_p=0.2}*d_adv_ineq*(1-woman)) - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /w_delta_n=/w_alpha
test /m_delta_n=/m_alpha
test /w_delta_p=/w_beta
test /m_delta_p=/m_beta
test /w_delta_n=/m_delta_n
test /w_delta_p=/m_delta_p


** Alternative 3, log of labor supply +5 lines
* Alternative 3, column 1: with demographics
eststo: nl (lnl_add5 = ( (1/{g=2})*(ln(w - {alpha=0.2}*dis_ineq - {beta=0.2}*adv_ineq - {delta_n=0.5}*d_dis_ineq - {delta_p=0.1}*d_adv_ineq)  - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /alpha=/delta_n
test /beta=/delta_p
* Alternative 3, column 3: with demographics
eststo: nl (lnl_add2 = ( (1/{g=2})*(ln(w - {w_alpha=0}*dis_ineq*woman -  {w_beta=0}*adv_ineq*woman - {w_delta_n=0}*d_dis_ineq*woman - {w_delta_p=0}*d_adv_ineq*woman - {m_alpha=0}*dis_ineq*(1-woman) - {m_beta=0}*adv_ineq*(1-woman) - {m_delta_n=-0.1}*d_dis_ineq*(1-woman) - {m_delta_p=0.2}*d_adv_ineq*(1-woman)) - {cons=-1} - {s2}*study2 - {s3}*study3 - {s4}*study6 - {a40}*age40 - {a50}*age50 - {a60}*age60 - {wom}*woman  - {uk}*nat_uk - {stu}*student - {emp}*employed - {approv}*num_approvals - {prolific}*prolific_score - {p1}*period1 - {p2}*period2 - {p3}*period3 - {p4}*period4 - {p6}*period6 - {p7}*period7 - {p8}*period8 - {p9}*period9 - {p10}*period10 - {p11}*period11 - {p12}*period12 - {p14}*period14 - {p15}*period15 - {p16}*period16 - {p17}*period17 - {p18}*period18 - {p19}*period19 - {p21}*period26 - {p22}*period27 - {p23}*period28) ) ) if alldemographics==1, vce(robust)
test /w_delta_n=/w_alpha
test /m_delta_n=/m_alpha
test /w_delta_p=/w_beta
test /m_delta_p=/m_beta
test /w_delta_n=/m_delta_n
test /w_delta_p=/m_delta_p
